package damo.test;

import praca.framework.FPSCounter;
import praca.framework.GraphicsGL;
import praca.framework.Sprite;
import praca.framework.SpriteBatcher;
import praca.framework.TextureAtlas;
import praca.framework.Vector;
import praca.framework.Vertices;
import praca.interfejsy.Game;
import praca.interfejsy.Screen;
import android.util.Log;

public class PlatekSnieguTest4 extends Screen{

	int NR = 1000;
	PlatekSniegu[] platki = new PlatekSniegu[NR];
	Vector gravity = new Vector(0 , -2);
	Vertices vert = new Vertices(100,100, true);
	TextureAtlas platek;
	FPSCounter fps = new FPSCounter();
	SpriteBatcher batcher;
	Sprite sprite;
	
	public PlatekSnieguTest4(Game game) {
		super(game);
		int len = platki.length;
		for(int i=0; i < len; i++){
			
			platki[i] = new PlatekSniegu();
		}
		
	}

	@Override
	public void update(float deltaTime) {
		g.drawColor(0, 0, 0);
		
		
		g.clearTransformations();
		((GraphicsGL)g).enableStateTexture();
		
		batcher.startBatch();
		int len = platki.length;
		for(int i=0; i < len; i++){
			
			platki[i].velocity.add(gravity.x* deltaTime, gravity.y* deltaTime);
			platki[i].position.add(platki[i].velocity.x * deltaTime, platki[i].velocity.y * deltaTime);

			batcher.drawSprite(sprite,100,100, platki[i].position.x, platki[i].position.y, 0);
			
			if(platki[i].position.y<-30){
				platki[i].reinitialize();
			}
			
		}
		
		batcher.endBatch();
		fps.logFrame2();
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		g.setTextureTransparentBackground();
		platek = new TextureAtlas("snowflake.png", game);
		sprite = new Sprite(platek, 0,0,128,128);
		batcher = new SpriteBatcher(platek, game, NR);
		
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
